package m.member.manage.model;

import m.common.model.FieldMeta;
import m.common.model.Model;
import m.common.model.TableMeta;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.ModelUpdateUtil;
import m.system.cache.FlushCache;

import java.util.List;

@TableMeta(name="t_app_setting",description="应用设置表")
public class AppSetting extends Model implements FlushCache {
    @FieldMeta(name="member_day_type",type= FieldType.STRING,description="会员日类型",dictOption = "N:无,A:按日,B:按星期")
    private String memberDayType;
    @FieldMeta(name="member_week_no",type= FieldType.STRING,length = 10,description="指定星期几",dictOption = "1:星期天,2:星期一,3:星期二,4:星期三,5:星期四,6:星期五,7:星期六")
    private String memberWeekNo;
    @FieldMeta(name="member_day_no",type= FieldType.STRING,length = 100,description="指定几号",dictOption = "01:1号,02:2号,03:3号,04:4号,05:5号,06:6号,07:7号,08:8号,09:9号,10:10号,11:11号,12:12号,13:13号,14:14号,15:15号,16:16号,17:17号,18:18号,19:19号,20:20号,21:21号,22:22号,23:23号,24:24号,25:25号,26:26号,27:27号,28:28号,29:29号,30:30号,31:31号")
    private String[] memberDayNo;

    @FieldMeta(name = "point_rate",type = FieldType.INT,description = "积分倍数")
    private Integer pointRate;
    @FieldMeta(name = "discount",type = FieldType.INT,description = "优惠比例%")
    private Integer discount;

    public String getMemberDayType() {
        return memberDayType;
    }

    public void setMemberDayType(String memberDayType) {
        this.memberDayType = memberDayType;
    }

    public String[] getMemberDayNo() {
        return memberDayNo;
    }

    public void setMemberDayNo(String[] memberDayNo) {
        this.memberDayNo = memberDayNo;
    }

    public String getMemberWeekNo() {
        return memberWeekNo;
    }

    public void setMemberWeekNo(String memberWeekNo) {
        this.memberWeekNo = memberWeekNo;
    }

    public Integer getPointRate() {
        return pointRate;
    }

    public void setPointRate(Integer pointRate) {
        this.pointRate = pointRate;
    }

    public Integer getDiscount() {
        return discount;
    }

    public void setDiscount(Integer discount) {
        this.discount = discount;
    }

    @Override
    public AppSetting getCacheModel(String s) throws Exception {
        List<AppSetting> ls= ModelQueryList.getModelList(AppSetting.class,"*");
        if(ls.size()>0){
            return ls.get(0);
        }else{
            AppSetting setting=new AppSetting();
            setting.setOid("1");
            setting.setMemberDayType("A");
            setting.setMemberWeekNo("1");
            setting.setMemberDayNo(new String[]{"01"});
            setting.setPointRate(200);
            setting.setDiscount(10);
            ModelUpdateUtil.insertModel(setting);
            return setting;
        }
    }
}
